.cmn-toggle {
  @extend %double-tap;
  position: absolute;
  margin-left: -99999px;
}

.cmn-toggle + label {
  display: block;
  position: relative;
  cursor: pointer;
  outline: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  padding: 1px;
  width: 40px;
  height: 24px;
  border: 1px solid $c-border;
  border-radius: 24px;

  &::before,
  &::after {
    display: block;
    position: absolute;
    content: '';
    width: 22px;
    height: 22px;
    bottom: 0;
    left: 0;
  }

  &::before {
    @extend %data-icon;
    font-size: 1em;
    z-index: 1;
    text-align: center;
    line-height: 22px;
  }

  &::after {
    @extend %metal;

    border-radius: 100%;
    box-shadow: 0 1px 2.5px rgba(0, 0, 0, 0.3);
  }
}

.cmn-toggle:not(:checked) + label {
  background-color: $c-bad;
}

.cmn-toggle--subtle:not(:checked) + label {
  background-color: $c-font-dimmer;
}

.cmn-toggle:checked + label {
  background-color: $c-good;
}

.cmn-toggle:disabled + label {
  opacity: 60%;
  cursor: not-allowed !important;
}

.cmn-toggle:focus:not(:disabled) + label {
  @extend %focus-shadow;
}

.cmn-toggle:hover:not(:disabled) {
  + label {
    @extend %focus-shadow;
    @include transition(background);

    &::before {
      transition: margin $transition-duration, color $transition-duration;
    }

    &::after {
      @extend %metal-hover;
      @include transition(margin);
    }
  }
}

.cmn-toggle:not(:checked) + label {
  &::before {
    content: '';
    color: $c-bad;
  }
}

.cmn-toggle--subtle:not(:checked) + label {
  &::before {
    color: $c-font-dimmer;
  }
}

.cmn-toggle:checked + label {
  &::before,
  &::after {
    margin-left: 16px;
  }

  &::before {
    content: '';
    color: $c-good;
  }
}
